import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CompanyService } from './company.service';
import {
  CreatePhotoDto,
  FindCompanyDto,
  UpdateCompanyAddressDto,
  UpdateCompanyBaseInfoDto,
  UpdateCompanyDto,
  UpdateCompanyIntroduceDto,
  UpdateCompanyWelfareDto,
  UpdateCompanyWorkTimeDto,
} from './company.dto';

@ApiTags('公司管理')
@ApiBearerAuth()
@Controller('company')
export class CompanyController {
  constructor(private companyService: CompanyService) {}

  @Get('list')
  @ApiOperation({ summary: '获取公司列表' })
  async getCompanyList(@Query() query: FindCompanyDto) {
    return await this.companyService.find(query);
  }

  @Get('detail/:id')
  @ApiOperation({ summary: '获取公司详细' })
  async getCompanyDetail(@Param('id') id: string) {
    return this.companyService.findOne(+id);
  }

  @Put('update/:id')
  @ApiOperation({ summary: '更新公司信息' })
  async updateCompany(@Param('id') id: string, @Body() updateCompanyDto: UpdateCompanyDto) {
    return await this.companyService.update(+id, updateCompanyDto);
  }

  @Put('update/base-info/:id')
  @ApiOperation({ summary: '更新公司基本信息' })
  async updateCompanyBaseInfo(
    @Param('id') id: string,
    @Body() updateCompanyDto: UpdateCompanyBaseInfoDto,
  ) {
    return await this.companyService.update(+id, updateCompanyDto);
  }

  @Put('update/work-time/:id')
  @ApiOperation({ summary: '更新公司工作时间' })
  async updateCompanyWorkTime(
    @Param('id') id: string,
    @Body() updateCompanyDto: UpdateCompanyWorkTimeDto,
  ) {
    return await this.companyService.update(+id, updateCompanyDto);
  }

  @Put('update/welfare/:id')
  @ApiOperation({ summary: '更新公司福利' })
  async updateCompanyWelfare(
    @Param('id') id: string,
    @Body() updateCompanyDto: UpdateCompanyWelfareDto,
  ) {
    return await this.companyService.update(+id, updateCompanyDto);
  }

  @Put('update/address/:id')
  @ApiOperation({ summary: '更新公司地址' })
  async updateCompanyAddress(
    @Param('id') id: string,
    @Body() updateCompanyDto: UpdateCompanyAddressDto,
  ) {
    return await this.companyService.update(+id, updateCompanyDto);
  }

  @Put('update/introduce/:id')
  @ApiOperation({ summary: '更新公司介绍' })
  async updateCompanyIntroduce(
    @Param('id') id: string,
    @Body() updateCompanyDto: UpdateCompanyIntroduceDto,
  ) {
    return await this.companyService.update(+id, updateCompanyDto);
  }

  @Post('photo')
  @ApiOperation({ summary: '上传公司图片' })
  async uploadCompanyPhoto(@Body() createPhotosDto: CreatePhotoDto) {
    return this.companyService.uploadPhoto(createPhotosDto);
  }

  @Delete('photo/:id')
  async deleteCompanyPhoto(@Param('id') id: string) {
    return this.companyService.deletePhoto(+id);
  }
}
